<template>
  <el-form :model="ruleForm"  ref="ruleForm" :label-position="type == 'detail' ? 'right' : 'top'">
    <!--客户信息-->
    <el-card class="box-card" shadow="never">

      <div slot="header" class="header-card">
        <span class="header-card-title">客户信息</span>
      </div>

      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="合同编码：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="合同时间：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="标准日租金：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>

        </el-col>
      </el-row>

      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="客户名称：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="所属归属城市：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>
        </el-col>

        <el-col :span="8">
          <el-form-item label="业务类型：" prop="vinNo" :rules="type!=='detail'? rules.vinNo : []">
            <el-input v-if="type!=='detail'" v-model="ruleForm.vinNo"></el-input>
            <span v-else>{{ ruleForm.vinNo }}</span>
          </el-form-item>
        </el-col>


      </el-row>


    </el-card>
  </el-form>
</template>

<script>

export default {
  mame: "clientMessage", // <!--客户信息-->


  props: {
    value: {
      type: Object,
      default: {},
    },
    state: {
      type: String,
      default: "",
    },
  },

  computed: {
    ruleForm: {
      get() {
        return this.value;
      },
      set(val) {
        this.$emit("input", val);
      },
    },
    type() {
      let status
      switch (this.state) {
        case 'write':
          status = 'edit'
          break
        case 'disabled':
          status = 'detail'
          break
        case 'readonly':
          status = 'detail'
          break
        case 'detail':
          status = 'detail'
          break
        case 'edit':
          status = 'edit'
        case 'add':
          status = 'add'
          break
      }
      return status
    },
  },

  watch: {},
  data() {
    return {
      rules: {
        vinNo: [
          {required: true, message: '请输入合同编码', trigger: 'blur'}
        ]
      }
    }
  },
  created() {
  },
  methods: {
    handleEffect() {
      return new Promise((resolve, reject) => {
        this.$refs.ruleForm.validate((valid) => {
          if (valid) {
            resolve();
          } else {
            this.locateToErr()
            reject();
          }
        });
      });
    },

    locateToErr() {
      this.$nextTick(() => {
        let isError = document.getElementsByClassName('is-error')
        isError[0].scrollIntoView({
          // 滚动到指定节点
          // 值有start,center,end，nearest，当前显示在视图区域中间
          block: 'center',
          // 值有auto、instant,smooth，缓动动画（当前是慢速的）
          behavior: 'smooth',
        })
      })
    },

    valid() {
      return new Promise((resolve) => {
        this.$refs.ruleForm.validate((valid) => {
          resolve(valid);
        });
      });
    },
  }
};
</script>

<style lang="scss" scoped>
@import "@/styles/cwgd/formScss.scss";
</style>


